/**
 * Created by arvin on 2017/5/25 0025.
 */
var menuTimer = null;
$(window).ready(function () {
    var mySwiper = new Swiper('.swiper-container',{
        autoplay : 5000,//可选选项，自动滑动
        loop : true,//可选选项，开启循环
        pagination:'.pagination',
        paginationClickable:true
    });

    $('.nav-items li a').hover(function(e){
        $('.menuBar ').removeClass('none');
        $('.menuBar .subMenu').addClass('none');
        $('.nav-items li.active').removeClass('active');
        $(this).parents('li').addClass('active');
        $('.menuBar .'+$(this).attr('data-index')).removeClass('none');
        clearTimeout(menuTimer);
    }).off('mouseleave').on('mouseleave',function(){

        menuTimer = setTimeout(function(){
            $('.nav-items li').removeClass('active');
            $('.menuBar ').addClass('none');
        },5000);
    });
    $('.menuBar').hover(function(e){
        clearTimeout(menuTimer)
    }).off('mouseleave').on('mouseleave',function(){
        menuTimer = setTimeout(function(){
            $('.nav-items li').removeClass('active');
            $('.menuBar ').addClass('none');
        },5000);
    });

    $('.nav-btn').off('click').on('click',function(){
        if($(this).data('state')!=='open'){
            $(this).data('state','open');
            $('.nav-items-xs').removeClass('none');
            menuTimer = setTimeout(function(){
                $('.nav-btn').data('state','close');
                $('.nav-items-xs').addClass('none');
            },5000);
        }else{
            clearTimeout(menuTimer);
            $('.nav-btn').data('state','close');
            $('.nav-items-xs').addClass('none');
        }

    })

});